package controller.v2;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import model.MemberVO;
import model.OrderBackVO;
import model.OrderEvaluateVO;
import model.OrderGoodVO;
import service.v2.MemberService;
import service.v2.OrderEvaluateService;
import service.v2.OrderService;
import util.PackageUtil;

@Controller
@RequestMapping("/v2/orderEvalu")
public class OrderEvaluateController {
	
	@Autowired
	private OrderEvaluateService orderEvaluateService;
	@Autowired
	private OrderService orderService;
	@Autowired
	private MemberService memberService;
	
	// 评价
	@ResponseBody
	@RequestMapping(value="/getEvalu",method=RequestMethod.GET) 
	public Object getEvalu(@RequestHeader (value="AUTHORIZATION", required=false) String token,@RequestHeader (value="SECRET", required=false)String member_id,
			MemberVO memberVO,/*@RequestParam(value="good_id",required=false)String good_id*/OrderEvaluateVO evaluateVO){
			
		int total = orderEvaluateService.getTotal(evaluateVO);
		evaluateVO.setPagination(evaluateVO.getPage_index(), total+"");
		List<OrderEvaluateVO>  OrderGoodList  = orderEvaluateService.getEvalueByGoodId(evaluateVO);
		int total_record = orderEvaluateService.getEvaluateToTalRecord(evaluateVO.getGood_id());

		int picNo  = 0;
		for (int i = 0; i < OrderGoodList.size(); i++) {
			if(OrderGoodList.get(i).getFold_id()!=null&&!OrderGoodList.get(i).getFold_id().equals("")){
				picNo = picNo + 1;
			}
		}
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("records", OrderGoodList);
			
			map.put("total_record", total_record);
			map.put("total_pic_record", picNo);
			map.put("pagination", evaluateVO);
			
		return PackageUtil.packageParams(200,"success",map,"");
	}
}